var baseUrl = "";
var returnUrl = "";
var isLogined=false;
var def_cookie_ukey="";
var instance;
var soundInit =false;
function openLogin(){	
	$('.p_login').openModal({ top:200, closeButton: '.cancelClose' });
}
function salert(content,title){
	if(title){
		$("#msg_title").html(title);
	}
	$("#msg_content").html(content);
	$('#salert').openModal({ top:200, closeButton: '.cancelClose,#closeAlert' });
}
/**
 * 判断用户登录插件
 */
function isLogin(){
	if($(".tLogin >a.logined").length>0){
		   isLogined=true;
	}else{
		   isLogined=false;
    }
}
function login(user,pwd) {
	if(isLogined){
		return;
	}
	var username=$("#"+user).val();
	if ($.trim(username) == "") {
		return;
	}
	var password = $("#"+pwd).val();
	if (password == "") {
		return;
	}
	var data = {
		username : username,
		password : password
	};
	$.ajax({
		url : baseUrl + "/jsonpUserLogin",
		type : "get",
		cache:false,
		jsonp: "suleback",
		data : data,
		dataType:"jsonp",
		success : function(result) {
			if (result.success) {				
				window.location.reload();
			} else {
				$("#loginErrorMsg").html(result.message);
			}
		}
	});
}
/* 改变登楼url去向 */
function changeUrl(url) {
	returnUrl = url;
}
function loginKeyPress(t) {
	var event = arguments.callee.caller.arguments[0] || window.event;// 消除浏览器差异
	if (event.keyCode == 13) {
		if(t==0){
			login("tbarUname","tbarPwd");
		}else if(t==1){
			login("modalUname","modalPwd");
		}
	}
}
function initSound(){
	instance = soundManager.createSound({
		  id: 'mySound',
		  url: '/resources/sound/notify.mp3',
		  autoLoad: true,
		  autoPlay: false,
		  debugFlash:false,
		  useConsole: false,
		  onload: function() {
		    soundInit=true;
		  },
		  volume: 100
		});
}

function speak(){
	if(soundInit){
		instance.play();
	}else{
		initSound();
	}
}
$(function(){
	isLogin();
	def_cookie_ukey=$.cookie("private_key");
	soundManager.setup({
		  url: '/resources/swf/',
		  wmode: 'transparent',
		  flashVersion: 9, // optional: shiny features (default = 8)
		  // optional: ignore Flash where possible, use 100% HTML5 mode
		  preferFlash: false,
		  debugMode:false,
		  onready: initSound
	});
}); 



